package com.modbus.constant;

/**
 * @author heyayun
 * @description 系统静态参数
 * @date 2021/3/22 17:25
 */
public class ModbusConstants {
    public static final int NUM_5 = 5;

    public static final int ERROR_OFFSET = 0x80;

    public static final int SYNC_RESPONSE_TIMEOUT = 2000;
    public static final int TRANSACTION_IDENTIFIER_MAX = 100;

    public static final int ADU_MAX_LENGTH = 260;
    public static final int M_BAP_LENGTH = 7;

    /**
     * 功能码
     * 0x01: 读线圈寄存器
     * 0x02: 读离散输入寄存器
     * 0x03: 读保持寄存器
     * 0x04: 读输入寄存器
     * 0x05: 写单个线圈寄存器
     * 0x06: 写单个保持寄存器
     * 0x0f: 写多个线圈寄存器
     * 0x10: 写多个保持寄存器
     */
    public class RtuFunction {
        /**
         * 0x01: 读线圈寄存器
         */
        public static final short CODE_1 = 0x01;
        /**
         * 0x03: 读保持寄存器
         */
        public static final short CODE_3= 0x03;
        /**
         * 0x05: 写单个线圈寄存器
         */
        public static final short CODE_5 = 0x05;
    }
}
